package com.kaka.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

import java.util.Arrays;

public class JDKAspect {
    public void before() {
        System.out.println("前置通知");
    }

    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("环绕通知");
        Object[] args = joinPoint.getArgs();
        Object proceed = joinPoint.proceed(args);
        System.out.println("环绕通知");
        return proceed;
    }

    public void after() {
        System.out.println("后置通知");
    }

    public void afterReturning(JoinPoint joinPoint, Object result) {
        System.out.println("返回通知");
        System.out.println(Arrays.toString(joinPoint.getArgs()));
        System.out.println(result);
    }

    public void afterThrowing(Exception e) {
        System.out.println("异常通知");
        System.out.println(e.getMessage());
    }
}
